package com.klhappy.houyuan.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.klhappy.houyuan.R;
import com.klhappy.houyuan.bean.SearchBean.Records;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by MrPu on 15/12/23.
 */
public class SearchListAdapter extends BaseAdapter {

    private Context context;
    private List<Records> recordses;

    public SearchListAdapter(Context context, List<Records> recordses) {
        this.context = context;
        this.recordses = recordses;
    }

    @Override
    public int getCount() {
        return recordses.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
        ViewHolder holder;
        if (view == null){
            view = LayoutInflater.from(context).inflate(R.layout.item_search_list ,null);
            holder = new ViewHolder();
            holder.setView(view);
            view.setTag(holder);
        }else {
            holder = (ViewHolder) view.getTag();
        }
        holder.tv_search.setText(recordses.get(position).getG_name());
        return view;
    }

    class ViewHolder{
        @InjectView(R.id.tv_search)
        TextView tv_search;

        public void setView(View view){
            ButterKnife.inject(this ,view);
        }
    }
}
